#ifndef __MULTICAST_RECEIVER_H
#define	__MULTICAST_RECEIVER_H

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <sys/ioctl.h>

#define DEFAULT_MULTICAST_IP ((char *)"224.0.1.1")

class MulticastReceiver
{

public:

    MulticastReceiver(char *localIp, int recvPort, char *multiIpAddr = DEFAULT_MULTICAST_IP);
    virtual ~MulticastReceiver();

    int Recv(char *buffer, int len);

private:

    bool isNormal = false;
    int sockfd = -1;

    int GetIfnameByIp(char *ip, char *ifname, int ifnameLen);
};

#endif